Client Side Template

{(logicalExpression ? trueResult : falseResult)}

Description

An inline if-else expression for creating a dynamic template.

The {(logicalExpression ? trueResult : falseResult)} command allows you to write an inline if-else statement. This allows you to create compact templates. For example, consider the following JSON data:

[
    {"Firstname": "John","Lastname": "Smith","City": "Boston","State": "MA"},
    {"Firstname": "Allison","Lastname": "Berman","City": "Los Angeles","State": "CA"},
    {"Firstname": "Amanda","Lastname": "Higgins","City": "Chicago","State": "IL"},
    {"Firstname": "Nancy","Lastname": "Clark","City": "Boston","State": "MA"}
]

Suppose you would display whether or not someone lives in Massachusetts. This can be done with the following template:

{Firstname} {Lastname} {(State == 'MA' ? "lives in" : "does not live in")} Massachusetts.<br>

This gives us the following results:

John Smith lives in Massachusetts.
Allison Berman does not live in Massachusetts.
Amanda Higgins does not live in Massachusetts.
Nancy Clark lives in Massachusetts.